Calkin–Wilf tree

In number theory, the Calkin–Wilf tree is a tree in which the vertices correspond 1-for-1 to the positive rational numbers. The tree is rooted at the number 1, and any rational number expressed in simplest terms as the fraction a/b has as its two children the numbers a/(a + b) and (a + b)/b. Every positive rational number appears exactly once in the tree.

The sequence of rational numbers in a breadth-first traversal of the Calkin–Wilf tree is known as the Calkin–Wilf sequence. Its sequence of numerators (or, offset by one, denominators) is Stern's diatomic series, and can be computed by the fusc function.

The Calkin–Wilf tree is named after Neil Calkin and Herbert Wilf, whose 2000 paper introduced it. Stern's diatomic series was formulated much earlier by Moritz Abraham Stern, a 19th-century German mathematician who also invented the closely related Stern–Brocot tree.

Contents

Definition and structure

The Calkin–Wilf tree may be defined as a directed graph in which each positive rational number a/b occurs as a vertex and has one outgoing edge to another vertex, its parent. We assume that a/b is in simplest terms; that is, the greatest common divisor of a and b is 1. If a/b < 1, the parent of a/b is a/(b − a); if a/b is greater than one, the parent of a/b is (a − b)/b. Thus, in either case, the parent is a fraction with a smaller sum of numerator and denominator, so repeated reduction of this type must eventually reach the number 1. As a graph with one outgoing edge per vertex and one root reachable by all other vertices, the Calkin–Wilf tree must indeed be a tree.

The children of any vertex in the Calkin–Wilf tree may be computed by inverting the formula for the parents of a vertex. Each vertex a/b has one child whose value is less than 1, a/(a + b), because this is the only value less than 1 whose parent formula leads back to a/b. Similarly, each vertex a/b has one child whose value is greater than 1, (a + b)/b.[1]

Although it is a binary tree (each vertex has two children), the Calkin–Wilf tree is not a binary search tree: its inorder does not coincide with the sorted order of its vertices. However, it is closely related to a different binary search tree on the same set of vertices, the Stern–Brocot tree: the vertices at each level of the two trees coincide, and are related to each other by a bit-reversal permutation.[2]

Breadth first traversal

The Calkin–Wilf sequence is the sequence of rational numbers generated by a breadth-first traversal of the Calkin–Wilf tree,

1/1, 1/2, 2/1, 1/3, 3/2, 2/3, 3/1, 1/4, 4/3, 3/5, 5/2, 2/5, 5/3, 3/4, ….

Because the Calkin–Wilf tree contains every positive rational number exactly once, so does this sequence.[3] The denominator of each fraction equals the numerator of the next fraction in the sequence. The Calkin–Wilf sequence can also be generated directly by the formula

q_{i%2B1} = \frac{1}{2\lfloor q_i\rfloor - q_i %2B 1},

where q_i denotes the ith number in the sequence, starting from q_0 =1, and \lfloor q_i \rfloor represents the integral part.[4]

Stern's diatomic sequence

Stern's diatomic sequence is the integer sequence

0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, 2, 5, 3, 4, … (sequence A002487 in OEIS).

The nth value in the sequence is the value fusc(n) of the fusc function,[5] defined by the recurrence relations fusc(2n) = fusc(n) and fusc(2n + 1) = fusc(n) + fusc(n + 1), with the base cases fusc(0) = 0 and fusc(1) = 1. The nth rational number in a breadth-first traversal of the Calkin–Wilf tree is the number fusc(n) / fusc(n + 1).[6] Thus, the diatomic sequence forms both the sequence of numerators and the sequence of denominators of the numbers in the Calkin–Wilf sequence.

The function fusc(n + 1) is the number of odd binomial coefficients of the form \scriptstyle {n-r\choose r},\ 0\leq 2r<n,[7] and also counts the number of ways of writing n as a sum of powers of two in which each power occurs at most twice. This can be seen from the recurrence defining fusc: the expressions as a sum of powers of two for an even number 2n either have no 1's in them (in which case they are formed by doubling each term an expression for n) or two 1's (in which case the rest of the expression is formed by doubling each term in an expression for n − 1), so the number of representations is the sum of the number of representations for n and for n − 1, matching the recurrence. Similarly, each representation for an odd number 2n + 1 is formed by doubling a representation for n and adding 1, again matching the recurrence.[8] For instance,

6 = 4 + 2 = 4 + 1 + 1 = 2 + 2 + 1 + 1

has three representations as a sum of powers of with at most two copies of each power, so fusc(6 + 1) = 3.

See also

Notes

  1. ^ The description here is dual to the original definition by Calkin and Wilf, which begins by defining the child relationship and derives the parent relationship as part of a proof that every rational appears once in the tree. As defined here, every rational appears once by definition, and instead the fact that the resulting structure is a tree requires a proof.
  2. ^ Gibbons, Lester & Bird (2006).
  3. ^ Calkin & Wilf (2000): "a list of all positive rational numbers, each appearing once and only once, can be made by writing down 1/1, then the fractions on the level just below the top of the tree, reading from left to right, then the fractions on the next level down, reading from left to right, etc." Gibbons, Lester & Bird (2006) discuss efficient functional programming techniques for performing this breadth first traversal.
  4. ^ Aigner & Ziegler (2004) credit this formula to Moshe Newman.
  5. ^ The fusc name was given to it in 1976 by Edsger W. Dijkstra; see EWD570 and EWD578.
  6. ^ Calkin & Wilf (2000), Theorem 1.
  7. ^ Carlitz (1964).
  8. ^ The OEIS entry credits this fact to Carlitz (1964) and to uncited work of Lind. However, Carlitz' paper describes a more restricted class of sums of powers of two, counted by fusc(n) instead of by fusc(n + 1).

References

External links